package org.styx.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @date 2021/10/14
 * @auther uranus
 */
@Configuration
public class TopicConfig {
    public static final String TOPIC_QUEUE_1="topic.queue1";
    public static final String TOPIC_QUEUE_2="topic.queue2";
    public static final String TOPIC_EXCHANG="topic.exchange";

    @Bean
    public Queue topicQueue1(){
        return new Queue(TOPIC_QUEUE_1);
    }
    @Bean
    public Queue topicQueue2(){
        return new Queue(TOPIC_QUEUE_2);
    }
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(TOPIC_EXCHANG);
    }
    @Bean
    public Binding topicBinding1(){
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with(
                "topic.message");
    }

    public Binding topicBinding2(){
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with(
                "topic.#");
    }

}
